﻿var page,path;

page = window.location.href;
page=page.slice(page.indexOf('-')==-1?page.indexOf('.html')+1:page.indexOf('-')+1,page.indexOf('.html'));
if(page=='') page='1';
page=parseInt(page);		

path=window.location.href;
path=path.slice(path.lastIndexOf('/')+1,path.indexOf('-')==-1?path.indexOf('.html'):path.indexOf('-'));

var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

if(totalpage > 1){
	document.onkeydown=function(e){
		var e = is_ie ? window.event : e;
		var tagname = is_ie ? e.srcElement.tagName : e.target.tagName;
		if(tagname.toUpperCase() == 'INPUT' || tagname.toUpperCase() == 'TEXTAREA'){
			return;
		}
		actualCode = e.keyCode ? e.keyCode : e.charCode;
		if(actualCode == 39 && page<totalpage) {
			window.location = path+'-' + (page+1)+'.html';
		}
		if(actualCode == 37 && page>1){	
			//alert(typeof(hasfp));		
			if(page!=2 || typeof(hasfp)=='number') {
				window.location = path+'-' + (page-1)+'.html';
			}
			else window.location = path+'.html';
		}
	}
}